import React, {Component} from 'react';
const FC = ({count}) => {
    console.log(count, 6666)
    return <div>FC{count}</div>
}
// 将FC纯组件话，就有类似class组件Pure的能力
const MemoFC = React.memo(FC)
class Example1 extends Component {
    state = {
        count: 0,
    }
    setCount = (count) => {
        this.setState({count})
    }

    add = () => {
        this.setCount(this.state.count + 1)
    }

    stay = () => {
        this.setCount(this.state.count)
    }
    render() {
        console.log(this.state.count, 6666)
        return (
            <div>
                <button onClick={this.add}>add</button>
                <button onClick={this.stay}>stay</button>
                {/*函数组件时随父组render重新计算而重新执行的，一旦不做渲染优化，就是无脑的，如果函数组件纯化，结果就不一样了*/}
                <MemoFC
                    count={this.state.count}
                />
            </div>
        );
    }
}

export default Example1;
